using System.Runtime.Serialization;
using Db4objects.Db4o;

namespace SharedObjects
{
	[DataContract]
	public abstract class Credential : EntityBase
	{
		public virtual SystemFile GetCredentialFileCopy(IObjectContainer db)
		{
			return null;
		}
	}

	[DataContract]
	public class UsernamePasswordCredential : Credential
	{
		[DataMember] public string Username { get; set; }
		[DataMember] public string Password { get; set; }
	}

	[DataContract]
	public abstract class FileCredential : Credential
	{
		/// <summary>
		/// this file does not exist in a directory, but can be copied(!) into one. It can never be deleted without deleting the dependent Credentials as well.
		/// The sole purpose of this class is to have a way to find the reference file for this user account.
		/// </summary>
		[DataMember]
		public CredentialFile ReferenceFile { get; set; }
		public override SystemFile GetCredentialFileCopy(IObjectContainer db)
		{
			if (ReferenceFile == null)
				return null;
			return ReferenceFile.Copy(db);
		}
	}

	[DataContract]
	public class FingerprintCredential : FileCredential
	{
	}

	[DataContract]
	public class RetinalScanCredential : FileCredential
	{
	}

	[DataContract]
	public class DnaCredential : FileCredential
	{
	}

	[DataContract]
	public class PsecCredential : FileCredential
	{
	}

	[DataContract]
	public class TbpaCredential : FileCredential
	{
		
	}

	public enum CredentialType
	{
		UsernamePassword,
		Fingerprint,
		Retinal,
		Dna,
		Psec,
		Tbpa
	}
}